<!-- 主页 -->
{% extends "base.html" %}
{% block title %}知识与你分享{% endblock %}
{% block content %}
    {% if username %}
	{% for post in posts %}
    <div class="user-profile-post" id="BG">
        <div class="row">
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                <div class="user-profile-post-name">
                    <h2><a href="/post/{{ post.id }}">{{ post.title }}</a></h2>
                    <p style="color: deeppink"><span>发布时间: {{ post.pub_date | date:'Y年m月d日, H:i'}}</span>
                    </p>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="profile-user-post-content">
                <div style="margin-top: -10px">
                {% if post.body|length > 20 %}
				    <p>{{ post.body | truncatechars:200 }}...</p>
                {% else %}
                    <p>{{ post.body | truncatechars:200 }}<p>
                {% endif %}
			    </div>
                    <div class="user-post-reply">
                        <div class="btn-group" style="margin-top: 10px">
                            <button class="btn btn-white btn-xs" onclick="javascrtpt:window.location.href='/post/{{ post.id }}'"><i class="fa big-icon fa-envelope"></i> 查看新闻</button>
                            <span class="btn btn-white btn-xs"><i class="fa big-icon fa-flask"></i> 热度：{% widthratio post.likes 1 10 %} EXP</span>
                            <span class="btn btn-white btn-xs" onclick="javascrtpt:window.location.href='/news/{{ post.keyword }}'"><i class="adminpro-icon adminpro-user-rounded author-log-ic"></i> {{ post.keyword }}</span>
                        </div>
                    <div style="float: right">
                        <a href="#">回到顶部</a>
                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

	{% endfor %}
<div style="text-align: center">
        <nav>
            <ul class="pagination">
                {% if posts.has_previous %}
                <li>
                    <a href="?page={{ posts.previous_page_number }}">
                        <span>&laquo;</span>
                    </a>
                </li>
                {% else %}
                <li class="disabled">
                    <a href="#">
                        <span>&laquo;</span>
                    </a>
                </li>
                {% endif %}
                {% for number in posts.paginator.page_range %}
                    {% if posts.number == number %}
                        <li class="active"><a href="?page={{ number }}">{{ number }}</a> </li>
                    {% else %}
                        <li><a href="?page={{ number }}">{{ number }}</a> </li>
                    {% endif %}
                {% endfor %}
                {% if posts.has_next %}
                    <li>
                        <a href="?page={{ posts.next_page_number }}">
                            <span>&raquo;</span>
                        </a>
                    </li>
                {% else %}
                    <li class="disabled">
                        <a href="#">
                            <span>&raquo;</span>
                        </a>
                    </li>
                {% endif %}
            </ul>
        </nav>
    </div>
    {% else %}
        {% include "login404.html" %}
    {% endif %}

{% endblock %}